package banking;

public class Customer {
    // 关联的银行账户
    private Account account;
    // 客户的名和姓
    private String firstName;
    private String lastName;
    
    // 构造方法，初始化客户姓名
    public Customer(String f, String l) {
        firstName = f;
        lastName = l;
    }
    
    // 获取客户的名
    public String getFirstName() {
        return firstName;
    }
    
    // 获取客户的姓
    public String getLastName() {
        return lastName;
    }
    
    // 获取客户关联的账户
    public Account getAccount() {
        return account;
    }
    
    // 为客户设置关联账户
    public void setAccount(Account acct) {
        account = acct;
    }
    
    // 主方法，用于测试Customer类功能
    public static void main(String[] args) {
        // 创建客户实例
        Customer customer = new Customer("John", "Doe");
        System.out.println("创建客户: " + customer.getLastName() + ", " + customer.getFirstName());
        
        // 创建账户并关联到客户
        Account account = new Account(1000.0);
        customer.setAccount(account);
        System.out.println("为客户设置初始余额为: " + customer.getAccount().getBalance());
        
        // 测试账户操作
        double depositAmount = 500.0;
        customer.getAccount().deposit(depositAmount);
        System.out.println("存入 " + depositAmount + " 后，余额为: " + customer.getAccount().getBalance());
        
        double withdrawAmount = 300.0;
        boolean withdrawSuccess = customer.getAccount().withdraw(withdrawAmount);
        if (withdrawSuccess) {
            System.out.println("取出 " + withdrawAmount + " 后，余额为: " + customer.getAccount().getBalance());
        } else {
            System.out.println("取出 " + withdrawAmount + " 失败，余额不足");
        }
    }
}
